<?php
declare(strict_types=1);
namespace Field;

class StoreProductAttrConst
{
    public const pk='SkuID';
    public const index=['SkuID'];
	public const fields=['SkuID','ProductID','Title','SubTitle','Content','VideoAttachID','AttachID','CreateAt','Status','IsDelete','Rank'];
	public const comment=['SkuID'=>'属性ID','ProductID'=>'','Title'=>'','SubTitle'=>'规格名字','Content'=>'商品详情','VideoAttachID'=>'','AttachID'=>'缩略图','CreateAt'=>'创建时间','Status'=>'状态','IsDelete'=>'删除','Rank'=>'排序'];
	/*
    * @Field SkuID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 属性ID
    */
    public const SkuID = 'SkuID';
    /*
    * @Field ProductID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const ProductID = 'ProductID';
    /*
    * @Field Title
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Title = 'Title';
    /*
    * @Field SubTitle
    * @Type varchar(200)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 规格名字
    */
    public const SubTitle = 'SubTitle';
    /*
    * @Field Content
    * @Type varchar(2000)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 商品详情
    */
    public const Content = 'Content';
    /*
    * @Field VideoAttachID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const VideoAttachID = 'VideoAttachID';
    /*
    * @Field AttachID
    * @Type int(10)
    * @Collation 
    * @Null NO
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 缩略图
    */
    public const AttachID = 'AttachID';
    /*
    * @Field CreateAt
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 创建时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field Status
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 状态
    */
    public const Status = 'Status';
    /*
    * @Field IsDelete
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 删除
    */
    public const IsDelete = 'IsDelete';
    /*
    * @Field Rank
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 9999
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 排序
    */
    public const Rank = 'Rank';
}

class StoreProductAttrColumns
{
public  int $SkuID;
   public  int $ProductID=0;
   public  ?string $Title='';
   public  string $SubTitle;
   public  string $Content;
   public  int $VideoAttachID=0;
   public  int $AttachID;
   public  int $CreateAt;
   public  int $Status;
   public  int $IsDelete;
   public  int $Rank=0;
	public function toArray():array
	{
		return [
'SkuID'=>$this->SkuID,
    'ProductID'=>$this->ProductID,
    'Title'=>$this->Title,
    'SubTitle'=>$this->SubTitle,
    'Content'=>$this->Content,
    'VideoAttachID'=>$this->VideoAttachID,
    'AttachID'=>$this->AttachID,
    'CreateAt'=>$this->CreateAt,
    'Status'=>$this->Status,
    'IsDelete'=>$this->IsDelete,
    'Rank'=>$this->Rank,        ];
	}
}

class StoreProductAttrRow
{
	public StoreProductAttrColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'SkuID' => $this->data->SkuID,
        'ProductID' => $this->data->ProductID,
        'Title' => $this->data->Title,
        'SubTitle' => $this->data->SubTitle,
        'Content' => $this->data->Content,
        'VideoAttachID' => $this->data->VideoAttachID,
        'AttachID' => $this->data->AttachID,
        'CreateAt' => $this->data->CreateAt,
        'Status' => $this->data->Status,
        'IsDelete' => $this->data->IsDelete,
        'Rank' => $this->data->Rank, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new StoreProductAttrColumns();
        isset($data['SkuID']) && $this->data->SkuID = (int)$data['SkuID'];
           isset($data['ProductID']) && $this->data->ProductID = (int)$data['ProductID'];
           isset($data['Title']) && $this->data->Title = (string)$data['Title'];
           isset($data['SubTitle']) && $this->data->SubTitle = (string)$data['SubTitle'];
           isset($data['Content']) && $this->data->Content = (string)$data['Content'];
           isset($data['VideoAttachID']) && $this->data->VideoAttachID = (int)$data['VideoAttachID'];
           isset($data['AttachID']) && $this->data->AttachID = (int)$data['AttachID'];
           isset($data['CreateAt']) && $this->data->CreateAt = (int)$data['CreateAt'];
           isset($data['Status']) && $this->data->Status = (int)$data['Status'];
           isset($data['IsDelete']) && $this->data->IsDelete = (int)$data['IsDelete'];
           isset($data['Rank']) && $this->data->Rank = (int)$data['Rank'];
    }
}
?>